package com.jeesite.modules.kj.api.vo.response;

import com.jeesite.modules.kj.api.wechatUtils.TokenUtils;
import com.jeesite.modules.kj.entity.KjMember;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * Author:hzy
 * Date:2021/07/04
 * Description:
 */
@Data
@ApiModel(value = "微信vo")
//@JsonInclude(JsonInclude.Include.ALWAYS)
public class WechatResponseVo {
    @ApiModelProperty(value = "token")
    private String token;

    @ApiModelProperty(value = "用户ID")
    private String id;
    @ApiModelProperty(value = "用户名")
    private String name;
    @ApiModelProperty(value = "手机号码")
    private String mobile;
    @ApiModelProperty(value = "openid")
    private String openid;
    @ApiModelProperty(value = "session_key")
    private String session_key;


    @ApiModelProperty(value = "是否需要更新头像")
    private String avatarUpdate;

    public WechatResponseVo(){

    }

    public WechatResponseVo(KjMember kjMember) {
        setEntity(kjMember);
    }
    public void setEntity(KjMember kjMember){
        this.name = kjMember.getName();
        this.mobile = kjMember.getMobile();
        this.id = kjMember.getId();
        this.token = TokenUtils.token(kjMember.getId());
        this.avatarUpdate = (kjMember.getHeadimg() == null || kjMember.getHeadimg().equals("https://ztefoundation.oss-cn-shenzhen.aliyuncs.com/fore-end-img/logo.png") ? "1" : "0");

    }
}
